package com.statistics.controller;

import com.statistics.bean.Water;
import com.statistics.service.EnvironmentService;
import com.statistics.service.EnvironmentTowerService;
import com.statistics.service.StatisticsService;
import com.statistics.service.WaterService;
import com.statistics.tools.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;

/**
 * @author MәӧωρaЯsε
 * @date 2017/7/13.
 */
@RestController
@RequestMapping("/app")
public class AppController {

    @Autowired
    private
    StatisticsService statisticsService;
    @Autowired
    private
    WaterService waterService;
    @Autowired
    private
    EnvironmentService environmentService;
    @Autowired
    private
    EnvironmentTowerService environmentTowerService;
    /**
     * App相关API
     */

    @RequestMapping(value = "/testDay", method = RequestMethod.POST)
    @ResponseBody
    public void testDay() throws ParseException {
        statisticsService.countEveryDay();
        return ;
    }

    @RequestMapping(value = "/testWaterDay", method = RequestMethod.POST)
    @ResponseBody
    public void testWaterDay() throws ParseException {
        System.err.println("waterService.countWaterEveryDay();");
        waterService.countWaterEveryDay();

        System.err.println("waterService.countWaterEveryWeek();");
        waterService.countWaterEveryWeek();

        System.err.println("waterService.countWaterEveryMonth();");
        waterService.countWaterEveryMonth();

        System.err.println("environmentService.countEnvEveryDay();");
        environmentService.countEnvEveryDay();

        System.err.println("environmentService.countEnvEveryWeek();");
        environmentService.countEnvEveryWeek();

        System.err.println("environmentService.countEnvEveryMonth();");
        environmentService.countEnvEveryMonth();

        System.err.println("environmentTowerService.countEnvTowEveryDay();");
        environmentTowerService.countEnvTowEveryDay();

        System.err.println("environmentTowerService.countEnvTowEveryWeek();");
        environmentTowerService.countEnvTowEveryWeek();

        System.err.println("environmentTowerService.countEnvTowEveryMonth();");
        environmentTowerService.countEnvTowEveryMonth();
        return ;
    }

    @RequestMapping(value = "/testEnvironmentDay", method = RequestMethod.POST)
    @ResponseBody
    public void testEnvironmentDay() throws ParseException {
        environmentService.countEnvEveryDay();
        return ;
    }

    @RequestMapping(value = "/testWeek", method = RequestMethod.POST)
    @ResponseBody
    public void testWeek() throws ParseException {
        statisticsService.countEveryWeek();
        return ;
    }

    @RequestMapping(value = "/testMonth", method = RequestMethod.POST)
    @ResponseBody
    public void testMonth() throws ParseException {
        statisticsService.countEveryMonth();
        return ;
    }


}
